package com.xbai.spark.core.action

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * count() 算子
  * 作用：返回 RDD 中元素的个数
  * 案例：创建一个RDD，统计该RDD的条数
  *
  * @author xbai
  * @Date 2020/12/31
  */
object Spark03_Count {

  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("count")
    val sc = new SparkContext(conf)

    val rdd: RDD[Int] = sc.parallelize(1 to 10)
    println(rdd.count())
    sc.stop()
  }
}
